package com.example.blogother.controller;


import com.ctc.wstx.sr.CompactNsContext;
import com.example.blogother.mapper.ChatMapper;
import com.xpd.blog.bean.Chat;
import com.xpd.blog.bean.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xpd
 * @since 2024-09-27
 */
@RestController
@RequestMapping("/chat")
public class ChatController {
    @Autowired
    ChatMapper chatMapper;
    @RequestMapping("selectChat")
    public List<Chat> selectChat(@RequestBody Chat chat){
        List<Chat> chats = chatMapper.selectByUsidOrderByUid(chat.getStatus());
        return chats;
    }
    @RequestMapping("insertChat")
    public Result insertChat(@RequestBody Chat chat){
        int insert = chatMapper.insert(chat);
        if(insert>0){
            return new Result(1,"发表成功",null);
        }else{
            return new Result(0,"发表失败",null);
        }
    }
}

